<template>
    <div style="height: 300px;" @touchmove.prevent @mousewheel.prevent>
      <div style="width:1000px; height: 450px; background:#fafafa;border:1px solid #eee;box-shadow:3px 3px #F5F5F5;margin-left: 200px; " >
          <b><legend style="height:85px; color:gray;margin-left: -850px;margin-top: -60px">快乐购用户注册</legend></b>
        <div style="width:450px; height: 350px; background:#fafafa;margin-top: 20px;" align="center">
      <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
         <el-form-item label="用户名:" prop="user" style="margin-top:50px">
    <el-input type="text" v-model="ruleForm.user" autocomplete="off" style="width:300px"></el-input>
  </el-form-item>
  <el-form-item label="密码:" prop="pass">
    <el-input type="password" v-model="ruleForm.pass" autocomplete="off" style="width:300px"></el-input>
  </el-form-item>
  <el-form-item label="确认密码:" prop="checkPass">
    <el-input type="password" v-model="ruleForm.checkPass" autocomplete="off" style="width:300px"></el-input>
  </el-form-item>
 <el-form-item label="验证码:" prop="check">
    <el-input v-model.number="ruleForm.check" style="width:100px; margin-left:-200px" ></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">注册</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
   <p style="margin-top: -60px"><el-checkbox label=" 我已阅读并同意 快乐购会员注册协议。"></el-checkbox></p>
</el-form>
        </div>

        <div class="zhuce"> 已有快乐购账号?
           <p style="margin-top: -100px"><router-link to="/LoginName"><el-button type="success" round>现在登录</el-button></router-link></p>
         <p class="img"></p>
         <p style="margin-top: -350px; margin-left: 200px;"><router-link to="/#">返回首页</router-link></p>
        </div>

        </div>
    </div>
</template>
<script>
  export default {
    data() {
      var validateuser = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入用户'));
        } else {
          if (this.ruleForm.user !== '') {
            this.$refs.ruleForm.validateField('user');
          }
          callback();
        }
      };
       var validateassword = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'));
        } else {
          if (this.ruleForm.password !== '') {
            this.$refs.ruleForm.validateField('password');
          }
          callback();
        }
      };
      var validatePass2 = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请再次输入密码'));
        } else if (value !== this.ruleForm.password) {
          callback(new Error('两次输入密码不一致!'));
        } else {
          callback();
        }
      };
      return {
        ruleForm: {
          user:'',
          password: '',
          checkPass: '',
          check: '',
          imgurl:require("@/assets/images/zhuce.png")
        },
        rules: {
           user: [
            { validator: validateuser, trigger: 'blur' }
          ],
          password: [
            { validator: validateassword, trigger: 'blur' }
          ],
          checkPass: [
            { validator: validatePass2, trigger: 'blur' }
          ],
        }
      };
    },
    methods: {
      submitForm(formName) {
       
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

<style>
.zhuce{
  border-left: 3px dotted gray;
  width: 350px;
  height:350px;
  margin-top: -350px;
  margin-left: 600px;
  font-size: 14px;
  

}
.img{
  background-image: url("@/assets/images/zhuce.png");
  width: 217px;
  height: 57px;
  margin-left: 100px;
}

</style>